/*------------------------------------------------------------------------
 *  Copyright (C) 2011  Luis M. de la Cruz
 *
 *  This file is part of TUNA
 *
 *  TUNA is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  TUNA is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ------------------------------------------------------------------------*/

#ifndef _GENERALMATRIX_H_
#define _GENERALMATRIX_H_

#include "Tuna.hpp"

namespace Tuna {

/*! 
 ***************************************************************************
 * General class for general matrix. 
 * This class is the root of the hierarchy for matrix objects. This is 
 * an "abstract" class from the point of view of the design, notwithstanding 
 * it is possible to define objects from this class as in:  
 * \c GeneralMatrix<DerivedClass> object; This feature is useful for  generic 
 * programming, in this case the functions \c calcPoints() and 
 * \c calcElements() should be implemented in the derived classes.
 ***************************************************************************
 *  \author  Luis M. de la Cruz [ Sat Jan 19 18:16:37 GMT 2011 ]
 *************************************************************************** 
 */
template<typename Tmat>
class GeneralMatrix {
    
public:
/*! Precision used for the numerical operations. */
  typedef typename Typeinfo<Tmat>::prec_t prec_t;     
/*! Arrays for numbers. */
  typedef typename TunaArray<prec_t,1>::huge ScalarField1D;
/*! Arrays for the different storage types. */
//  typedef typename TunaArray<prec_t,2>::huge CStore_t;


  typedef typename TunaArray<prec_t, Typeinfo<Tmat>::Dim >::huge compArray;
  typedef Array< compArray, 1> CStore_t;
  
  GeneralMatrix() { 
    Dim = Typeinfo<Tmat>::Dim; 
    //    cout << "\n GeneralMatriz \n" ;
  }
  ~GeneralMatrix() { }

/*!    
 * This funtion gets an returns a reference to the derived class,
 * using the Curiously Recurring Template Pattern (CRTP). 
 */
  Tmat& asDerived() { return static_cast<Tmat&>(*this); }    

/*!
 *  Returns the dimension of the matrix
 */
  inline int getDimension() { return Dim; }

/*!
 *  Returns the number of rows of the matrix
 */
  inline int getRows() { return rows; }

/*!
 *  Returns the number of rows of the matrix
 */
  inline int getCols() { return cols; }

/*! 
 *  Delegate responsabilities to derived classes. 
 */
//  bool calcPoints()   { return asDerived().calcPoints(); }  

  
protected:
  unsigned int Dim;               ///< Dimension 
  unsigned int rows, cols;

public:
  CStore_t store;

private:

};

} // Tuna namespace 


#endif //_GENERALMATRIX_H_



